// 引入依赖包
// 最低SDK版本要求：imageenhan20190930的SDK版本需大于等于1.0.12。
// 可以在此仓库地址中引用最新版本SDK：https://mvnrepository.com/artifact/com.aliyun/imageenhan20190930
// <dependency>
//       <groupId>com.aliyun</groupId>
//       <artifactId>imageenhan20190930</artifactId>
//       <version>${aliyun.imageenhan.version}</version>
// </dependency>

import com.aliyun.imageenhan20190930.models.GenerateImageWithTextResponse;
import com.aliyun.imageenhan20190930.models.GetAsyncJobResultRequest;
import com.aliyun.tea.TeaException;
import com.aliyun.tea.TeaModel;



public class GenerateImageWithText {
    public static com.aliyun.imageenhan20190930.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                // 必填，您的 AccessKey ID
                .setAccessKeyId(accessKeyId)
                // 必填，您的 AccessKey Secret
                .setAccessKeySecret(accessKeySecret);
        // 访问的域名
        config.endpoint = "imageenhan.cn-shanghai.aliyuncs.com";
        return new com.aliyun.imageenhan20190930.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        // "YOUR_ACCESS_KEY_ID", "YOUR_ACCESS_KEY_SECRET" 的生成请参考https://help.aliyun.com/document_detail/175144.html
        // 如果您是用的子账号AccessKey，还需要为子账号授予权限AliyunVIAPIFullAccess，请参考https://help.aliyun.com/document_detail/145025.html
        com.aliyun.imageenhan20190930.Client client = GenerateImageWithText.createClient(
                "LTAIBqFbkm0FZ1K6",
                "1inhunDMjbB7nsDvac2vI1JtPaRjBn");
        com.aliyun.imageenhan20190930.models.GenerateImageWithTextRequest generateImageWithTextRequest = new com.aliyun.imageenhan20190930.models.GenerateImageWithTextRequest()
                .setText("睡莲")
                .setResolution("1024*1024")
                .setNumber(1);
        com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
        try {
            GenerateImageWithTextResponse generateImageWithText = client.generateImageWithTextWithOptions(generateImageWithTextRequest, runtime);
            // 获取整体结果。
            System.out.println(com.aliyun.teautil.Common.toJSONString(TeaModel.buildMap(generateImageWithText)));
            // 获取单个字段。
            System.out.println(generateImageWithText.getBody());
        } catch (TeaException teaException) {
            // 获取整体报错信息。
            System.out.println(com.aliyun.teautil.Common.toJSONString(teaException));
            // 获取单个字段。
            System.out.println(teaException.getCode());
        }

    }
}
